package org.fnzn.actlistener;

import java.util.List;
import java.util.Map;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.fnzn.util.SpResultType;

/**
 * 贷审会执行后监听
 * 通过率大于60%通过
 * @author zhaolulu
 *
 */
public class ExecutionPendTrialAfterListener implements ExecutionListener{

	private static final long serialVersionUID = 1L;

	@Override
	@SuppressWarnings("unchecked")
	public void notify(DelegateExecution execution) throws Exception {
		Map<String,Object> map = execution.getVariables();
		int passCount=(int) map.get("passCount");//通过数量		
		List<String> userList=(List<String>) map.get("userList");//实例总数
		double passRate=(double)passCount/userList.size();
		if(passRate>=0.6){
			execution.setVariable("flag", SpResultType.AGREE.getCode());
		}else{
			execution.setVariable("flag", SpResultType.NO_AGREE.getCode());
		}
		
	}

}
